<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字符串的方法</title>
</head>
<body>
    <script>
        let str = "123abc456DEF";
        console.log("原字符串:",str);
        // console.log('下标为1的字符串是:',str.charAt(1));
        // console.log("把字符串转为大写:",str.toUpperCase());
        // console.log("把字符串转为小写:",str.toLowerCase());
        // console.log("查找abc在str中首次出现的位置:",str.indexOf("abc"));
        // console.log("查找xyz在str中首次出现的位置:",str.indexOf("xyz"));
        // console.log("返回索引6和9之间的字符串:",str.substring(6,9));
        // console.log("把字符串分给为字符串数组:",str.split(""));
        // console.log("把DEF替换为789:",str.replace("DEF","789"));

        let str2 = "jack,tom,mike";
        console.log("原字符串",str2)
        let arr = str2.split(",");
        for(let i = 0; i < arr.length; i++){
            let name = arr[i].substring(0,1).toUpperCase() + arr[i].substring(1)
            console.log(name)
            arr[i] = name
        }
        str2 = arr.join(",")
        console.log("修改完成",str2)
    </script>
</body>
</html>